//
//  BQSearchViewController.m
//  BeeQuick
//
//  Created by Asun on 2017/7/11.
//  Copyright © 2017年 BecomeRich. All rights reserved.
//

#import "BQSearchViewController.h"
#import "BQSearchView.h"
#import "BQSearchResultController.h"

@interface BQSearchViewController ()<UISearchBarDelegate>

@end

@implementation BQSearchViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UISearchBar* search = [[UISearchBar alloc]initWithFrame:CGRectMake(0,0 , 300, 30)];
    
    search.searchBarStyle = UISearchBarStyleMinimal;
    
    search.placeholder = @"请输入商品名称";
    
    search.delegate = self;
    
    self.navigationItem.titleView = search;
    
    self.navigationController.navigationBar.translucent = NO;
    
    BQSearchView *searchView = [[BQSearchView alloc]initWithFrame:self.view.bounds];
    
    [self.view addSubview:searchView];
    
    for (UIView* subView in searchView.subviews) {
        if ([subView isKindOfClass:[UIButton class]]) {
            
            UIButton *btn = (UIButton *)subView;
            
            [btn addTarget:self action:@selector(clickButton:) forControlEvents:UIControlEventTouchUpInside];
            
        }
    }
 
}

- (void)clickButton:(UIButton *)button{

    BQSearchResultController* result = [[BQSearchResultController alloc]init];
    
    [self.navigationController pushViewController:result animated:YES];
}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    
    BQSearchResultController *result = [[BQSearchResultController alloc]init];
    
    [self.navigationController pushViewController:result animated:YES];
}


@end
